import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
	base: './',
	plugins: [
		vue(),
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url))
		}
	},
	server: {
		host: '0.0.0.0',
		port: 8080,
		proxy: {
			'/digitalApi': {
				target: 'https://www.gdnos.com.cn/digitalApi',
				// target: 'http://127.0.0.1:8888',
				changeOrigin: true, //是否跨域
				rewrite: (path) => path.replace(/^\/digitalApi/, '')
				// secure: true, //false为http访问，true为https访问
			}
		},
		headers: {
			'Access-Control-Allow-Origin': '*'
		}
	},
	optimizeDeps: {
		include: ['eslint-plugin-vue', 'prettier'],
	},
})
